package com.zhentao.controller;


import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.common.pojo.management.TbRole;
import com.zhentao.service.ITbRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mp
 * @since 2025-01-03
 */
@RestController
@RequestMapping("/role")
public class TbRoleController {
    @Autowired
    private ITbRoleService tbRoleService;

    //增
    @PostMapping("/add")
    /**
     * @description:添加角色
     * @author: muhaoyang
     * @date: 2025/1/6 10:26
     * @param: [tbRole]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult addRole(@RequestBody TbRole tbRole){
        return tbRoleService.addRole(tbRole);
    }
    //删
    @DeleteMapping("/delete")
    /**
     * @description:删除角色
     * @author: muhaoyang
     * @date: 2025/1/6 10:27
     * @param: [id]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult deleteRole(@RequestParam(value = "id")Integer id){
        return tbRoleService.deleteRole(id);
    }
    //改
    @PutMapping("/update")
    /**
     * @description:修改角色
     * @author: muhaoyang
     * @date: 2025/1/6 10:28
     * @param: [tbRole]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult updateRole(@RequestBody TbRole tbRole){
        return tbRoleService.updateRole(tbRole);
    }
    //查
    @GetMapping("/list")
    /**
     * @description:获取角色列表
     * @author: muhaoyang
     * @date: 2025/1/6 10:29
     * @param: [roleName]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult getRoleList(@RequestParam(value = "roleName",required = false) String roleName){
        return tbRoleService.getRoleList(roleName);
    }
}

